package com.yuhq;


import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.Date;

public class SpringMyBatisTestScope {

    private ApplicationContext context;

    @Before
    public void init() {
        context = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
    }

    @Test
    public void testSpring() {
        //单例 全局唯一，容器启动时就创建好了
        //多例 全局不唯一，容器启动不会创建，调用时创建，每次调用都会返回一个新的对象
        Date date = (Date) context.getBean("date");
        System.err.println(date.hashCode());

         date = (Date) context.getBean("date");
        System.err.println(date.hashCode());
    }

}
